﻿using System;
using System.Threading.Tasks;
using winS.winML;

namespace winS.Unity.Serialization
{
    public class Serializer
    {
        private readonly WinMLSerializer winMLSerializer = new WinMLSerializer();

        public Serializer()
        {
            WinMLForUnity.AddToSerializer(winMLSerializer);
        }

        public string Serialize(object data)
        {
            return winMLSerializer.Serialize(data);
        }
        public void Serialize(object data, string filePath)
        {
            winMLSerializer.Serialize(data, filePath);
        }
        public void Serialize(object data, string saveDirectory, string fileName, string extension)
        {
            winMLSerializer.Serialize(data, saveDirectory, fileName, extension);
        }
        public Task<string> SerializeAsync(object data)
        {
            return winMLSerializer.SerializeAsync(data);
        }
        public Task SerializeAsync(object data, string filePath)
        {
            return winMLSerializer.SerializeAsync(data, filePath);
        }
        public Task SerializeAsync(object data, string saveDirectory, string fileName, string extension)
        {
            return winMLSerializer.SerializeAsync(data, saveDirectory, fileName, extension);
        }

        public void AddCustomSerializationFunction<T>(Func<T, string> serializationFunction)
        {
            winMLSerializer.AddSerializationFunction(serializationFunction);
        }
    }
}